home *** CD-ROM | disk | FTP | other *** search
Wrap
/* ** $VER: AwebMailTo.thor v1.33 (29.07.96) Shaun Downend. ** <shaund@amiganut.demon.co.uk> ** ** This is a very simple script designed for use with AWeb's mailto: ** support. It will take the email address supplied by AWeb and start ** a text editor of your choice and automatically fill in the To: field. ** When you have finished you save the message and it will appear as an ** event in Thor. ** ** Configuration in AWeb (1.2b) :- ** ** Unfortunately it appears that AWeb does not inherit the DOS path, that ** is why I have used the full path of RX below. ** ** Enter Change Settings. ** ** Network3: External programs ** Type: mailto: ** Command: sys:rexxc/rx ** Arguments: Thor:rexx/AWebMailTo.thor %s ** ** Configuration in this script:- ** ** MailSystem is the name of your TCP system in THOR, and MailConfName is ** obviously the name of your email conference in THOR. ** ** Setting AddSignature to 'Y' will make AwebMailTo.thor read your conference/ ** BBS/global signature settings and add that signature to your mails. ** ** Set Editor to the text editor of your choice. ** ** Sending a mailto: with AWeb should now produce an EnterMsg event in THOR. ** The mail will be sent the next time you use Send Events from ConnectTHOR. ** ** Note: THOR does not have to be running for this script to work! ** ** History: ** ¯¯¯¯¯¯¯¯ ** AWebMailTo.thor v1.1 (02.04.96) is based on SendMail.thor 1.10 by Troels ** Walsted Hansen. ** v1.2 (18.06.96) Fixed to support ced which requires a ** larger stack than default. Temporary ** files were not deleted upon an error. ** v1.3 (21.06.96) Added optional immediate sending of events. ** v1.31 (10.07.96) Added support for Miami TCP/IP stack. ** (23.07.96) Now uses Thor's TCP Systems config to ** find the mailserver address. ** v1.32 (23.07.96) Now uses $thor/thorpath to find the path ** to Thor. ** v1.33 (29.07.96) Fixed a stupid bug which was introduced in ** v1.32 would cause the script to error if ** AddSignature was set to 'N'. */ MailSystem = 'Internet' MailConfName = 'EMail' AddSignature = 'Y' /* Add signature from Thor (Y/N) */ SendEvent = 'Y' /* Send event immediately (Y/N) */ Editor = 'c:ced -keepio' /* insert '-pubscreen=AWeb' after -keepio for the editor * * to open on AWeb's public screen. */ /* To use GoldED for your editor use the following * * Editor = 'c:ED STICKY CONFIG GOLDED:Config/AWeb.prefs' */ /* DON'T CHANGE ANYTHING BELOW HERE */ Tempfile = 't:MailTo.msg.'||time(s)'.aweb' parse arg argument template = 'ADDRESS/A' if(argument = '' | argument = '?') then do say '$VER: AWebMailTo.thor V1.33 (29.07.96) Shaun Downend.' say 'Template:' template exit end if ~show('p', 'BBSREAD') then do address command "run >nil: `GetEnv THOR/THORPath`bin/LoadBBSRead" "sys:rexxc/WaitForPort BBSREAD" end address BBSREAD READARGS template ARGS CMDLINE argument if(rc ~= 0) then do say BBSREAD.LASTERROR exit end address command 'c:echo >'tempfile' "To: 'ARGS.ADDRESS'*NSubject: *N"' call pragma('s',8000) address command ''Editor' 'tempfile'' call pragma('s',4096) if(~OPEN(fh,tempfile,'Read')) then do say 'Unable to open file' exit end str = readln(fh) if(upper(word(str, 1)) ~= "TO:") then do call showerror("First headerline wasn't a To:, please don't mess with the header AWeb provides.") call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end else EVENT.TOADDR = word(str, 2) str = readln(fh) if(upper(word(str, 1)) ~= "SUBJECT:") then do call showerror("Second headerline wasn't a Subject:, please don't mess with the header AWeb provides.") call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end else EVENT.SUBJECT = substr(str, 10) /* skip X-Mailer: line */ call readln(fh) /* put the body of the message in a file with a unique name */ UNIQUEMSGFILE bbsname '"'MailSystem'"' stem UNIQUEFILE if(rc ~= 0) then do call showerror('UNIQUEMSGFILE BBSRead command failed: ' || BBSREAD.LASTERROR) call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end call open(tmp, UNIQUEFILE.NAME, W) do until eof(fh) call writeln(tmp, readln(fh)) end /* add signature from the EMail conference/BBS/Global Settings */ if(upper(AddSignature) = 'Y') then do GETCONFDATA BBSNAME '"'MailSystem'"' CONFNAME '"'MailConfName'"' STEM CONFD if(CONFD.SIGNATURE = "") then do GETBBSDATA BBSNAME '"'MailSystem'"' STEM BBSD if(BBSD.SIGNATURE = "") then do GETGLOBALDATA STEM GLOBD if(GLOBD.SIGNATURE = "") then do call showerror('No signature configured in either conference, bbs or global settings! Please correct this in THOR or turn off signature adding in AWebMailTo.thor.') call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end else sig = GLOBD.SIGNATURE end else sig = BBSD.SIGNATURE end else sig = CONFD.SIGNATURE drop CONFD.; drop BBSD.; drop GLOBD. if(sig ~= "") then do /* signature may be a filename */ if(exists(sig)) then do call open(sigfh, sig, R) do until eof(sigfh) call writeln(tmp, readln(sigfh)) end call close(sigfh) end else call writeln(tmp, sig) /* or just a string */ end end call close(tmp) /* fill out some more variables that BBSREAD require */ EVENT.CONFERENCE = MailConfName EVENT.MSGFILE = UNIQUEFILE.FILEPART /* write the event */ WRITEBREVENT bbsname '"'MailSystem'"' event 0 stem EVENT if(rc ~= 0) then do call showerror('WRITEBREVENT BBSRead command failed: ' || BBSREAD.LASTERROR) call close(fh) address command 'c:delete >NIL: 'tempfile'' exit end call close(fh) address command 'c:delete >NIL: 'tempfile'' if upper(sendevent) = "Y" then call send exit 0 /* sophisticated errorhandling :-) */ showerror: procedure expose MailSystem MailConfName AddSignature Editor parse arg errormsg p=show('P',,) if(pos('AWEB.', p) > 0) then awebport = word(substr(p, pos('AWEB.', p)), 1) else return call open(err, "T:AWebMailTo.thor.error.html", W) call writeln(err, "<HTML><HEAD><TITLE>AWebMailTo.thor encountered an error</TITLE></HEAD><BODY><H1>Sending mail aborted</H1>" || errormsg || "<P>Please remember to verify the following settings:<PRE>MailSystem = '" || MailSystem || "'" || '0a'x || "MailConfName = '" || MailConfName || "'" || '0a'x || "AddSignature = '" || AddSignature || "'" '0a'x || "Editor = '" || Editor || "'" '0a'x || "</PRE>If they are wrong, edit AWebMailTo.thor and correct them. <hr> If this should happen to be an erroneous error, don't hesitate to contact the author, <A HREF=" || '"' || "http://www.geocities.com/SiliconValley/8315" || '"' || ">Shaun Downend</A>, preferably by <A HREF=" || '"' || "mailto:shaund@amiganut.demon.co.uk" || '"' || ">email</A>.") call close(err) address(awebport) 'OPEN URL file://localhost/T:AWebMailTo.thor.error.html' return send: If Show('p', 'AMITCP') | Show('p', 'MIAMI.1') = 1 then do address BBSREAD GETBBSDATA SystemName stem BBSDATA if BBSDATA.NUMEVENTS ~= 0 then address command 'run >NIL: `getenv thor/thorpath`bin/SendTCP 'MailSystem' pubscreen=Workbench' end return